<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function getRandomColor(flag){
            if(flag===true){
                 let h='#'
        let arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
                for(let i=0;i<6;i++){
                    h += arr[ran(1,15)]
                }
                 return h
            }else{
              let  r=sj1
              let  g=sj2
              let  b=sj3
                num=(`(${r},`+`${g},`+`${b})`)
                return num
            }
        }
        function ran(N,M){
        return Math.floor(Math.random()*(M-N+1))+N
    }
    let sj1=ran(1,255)
    let sj2=ran(1,255)
    let sj3=ran(1,255)
       console.log(getRandomColor(true))   //#ffffff
       console.log(getRandomColor(false))   //rgb(255,255,255)
    </script>
</body>
</html>